package com.example.app.components.MyListItem

import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItemColors
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.example.app.ui.theme.shapeLarge

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun MyListItem(
    headlineContent: @Composable () -> Unit,
    modifier: Modifier = Modifier.clip(
        RoundedCornerShape(
            shapeLarge
        )
    ),
    overlineContent: @Composable (() -> Unit)? = null,
    supportingContent: @Composable (() -> Unit)? = null,
    leadingContent: @Composable (() -> Unit)? = null,
    trailingContent: @Composable (() -> Unit)? = null,
    tonalElevation: Dp = ListItemDefaults.Elevation,
    shadowElevation: Dp = ListItemDefaults.Elevation,
    hasWrap: Boolean = false,
    //containerColor的颜色，白色
    colors: ListItemColors = ListItemDefaults.colors(
        containerColor = MaterialTheme.colorScheme.surface
    ),
    //wrap的颜色，灰色
    myListItemWrapColumnBackgroundColor: Color = MaterialTheme.colorScheme.background
) {
    if (hasWrap) {
        MyListItemWrapColumn(
            myListItemWrapColumnBackgroundColor = myListItemWrapColumnBackgroundColor
        ) {
            ListItem(
                headlineContent,
                modifier,
                overlineContent,
                supportingContent,
                leadingContent,
                trailingContent,
                colors,
                tonalElevation,
                shadowElevation
            )
        }
    } else {
        ListItem(
            headlineContent,
            modifier,
            overlineContent,
            supportingContent,
            leadingContent,
            trailingContent,
            colors,
            tonalElevation,
            shadowElevation
        )
    }
}